import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    proxy: {
      '/auth': {
        target: 'http://localhost:9002',
        changeOrigin: true
      },
      '/data': {
        target: 'http://localhost:9002',
        changeOrigin: true
      },
      '/api': {
        target: 'http://localhost:9002',
        changeOrigin: true
      },
      // SGS DFF API代理，用于处理DFF更新请求
      '/gpo-api/ai/tool/update': {
        target: 'https://cnapp-uat.sgs.net',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/gpo-api/, '/gpo-micro-api'),
        secure: true
      },
      // SGS GPO API代理，用于处理其他gpo-api请求
      '/gpo-api': {
        target: 'https://cnapp-uat.sgs.net',
        changeOrigin: true,
        secure: true
      }
    }
  }
})
